﻿using System;
using System.IO;
using System.IO.Packaging;

namespace SpCop
{
    internal class ExtractedPackage : IDisposable
    {
        private Package _package;
        private readonly string _folderPath;
        private readonly string _path;

        public ExtractedPackage(string path, string folderPath)
        {
            _path = path;
            _folderPath = folderPath;
            Directory.CreateDirectory(_folderPath);
            _package = Package.Open(path, FileMode.Open, FileAccess.Read);
            //_extract = new Extract();
            //_extract.ExtractFile(path, _folderPath);
        }

        #region IDisposable Members

        public void Dispose()
        {
            Dispose(true);
        }

        #endregion

        public void Dispose(bool disposing)
        {
            if (disposing)
            {
                _package.Close();
              //  _extract.CleanUp();

                // Directory.Delete(_folderPath, true);

                GC.SuppressFinalize(this);
            }
        }


        ~ExtractedPackage()
        {
            Dispose(false);
        }
    }
}